//
//  eightTableViewCell.m
//  微运营
//
//  Created by 李光耀 on 16/3/22.
//  Copyright © 2016年 李光耀. All rights reserved.
//

#import "eightTableViewCell.h"
#import "eightTableViewCollectionViewCell.h"

@implementation eightTableViewCell

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc]init];
        layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
        layout.itemSize = CGSizeMake(([UIScreen mainScreen].bounds.size.width - 40)/4, 80);
        layout.minimumInteritemSpacing = 10;
        layout.minimumLineSpacing = 10;
        layout.sectionInset = UIEdgeInsetsMake(0, 10, 0, 10);
        
        self.collectionView = [[UICollectionView alloc]initWithFrame:CGRectZero collectionViewLayout:layout];
        _collectionView.delegate = self;
        _collectionView.dataSource = self;
        _collectionView.pagingEnabled = YES;
        //        _collectionView.bounces = NO;
        _collectionView.showsHorizontalScrollIndicator = NO;
        
        
        [self.collectionView registerClass:[eightTableViewCollectionViewCell class] forCellWithReuseIdentifier:@"eightTableViewCollectionViewCellIdentifier"];
        _collectionView.backgroundColor = [UIColor whiteColor];
        
        [self addSubview:self.collectionView];
        
        
        
    }
    return self;
}

- (void)layoutSubviews{
    [super layoutSubviews];
    
    _collectionView.frame = CGRectMake(0, 10, [UIScreen mainScreen].bounds.size.width , self.frame.size.height - 30);
}

- (void)setArray:(NSMutableArray *)array{
    if (_array != array) {
        _array = array;
    }
    
    [_collectionView reloadData];
    
    
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
#warning 暂时先8个
    return 8;
//    return self.array.count;
}

-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    eightTableViewCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"eightTableViewCollectionViewCellIdentifier" forIndexPath:indexPath];
//    cell.backgroundColor = [UIColor grayColor];
    cell.picimageView.image = [UIImage imageNamed:@"nopic"];
//    cell.label.backgroundColor = [UIColor yellowColor];
    cell.label.text = @"微运营前";
    return cell;
}




@end
